﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;

using BusinessManagementStudio.Models.BusinessObject.Entities;
using MongoDB.Driver.Builders;
using MongoDB.Driver.Linq;

namespace BusinessManagementStudio.Models.BusinessObject.Services
{
    public class FMService : EntityService<FM>
    {
        public List<FM> GetAllFMs()
        {
            return (from FManagment in this.MongoConnectionHandler.MongoCollection.FindAllAs<FM>()
                    select FManagment).ToList();
        }

        public List<SelectListItem> GetFMList()
        {
            List<SelectListItem> FMsList = new List<SelectListItem>();

            List<FM> AllFMsList = GetAllFMs().OrderBy(x => x.FMID).ToList();

            foreach (FM fm in AllFMsList)
            {
                SelectListItem sListItem = new SelectListItem();
                sListItem.Text = fm.FMName + fm.FMID;
                sListItem.Value = fm.FMName + fm.FMID;

                FMsList.Add(sListItem);
            }

            return FMsList;
        }

        public IEnumerable<SelectListItem> GetFMNameList()
        {
            return GetFMList();
        }

        public override void Update(FM entity)
        {
            //// Not necessary for the example
        }
    }
}